package com.sitanyun.merchant.guide.frament.model.impl;

import com.google.gson.Gson;
import com.sitanyun.merchant.guide.bean.UpdateNameBean;
import com.sitanyun.merchant.guide.callback.StringCallbacks;
import com.sitanyun.merchant.guide.frament.model.inter.IUpdateNameAModel;
import com.sitanyun.merchant.guide.frament.presenter.callback.CallBack;
import com.sitanyun.merchant.guide.url.Urls;
import com.sitanyun.merchant.guide.weiht.SharedPreferenceUtil;
import com.zhy.http.okhttp.OkHttpUtils;

import java.util.HashMap;

import okhttp3.Call;
import okhttp3.MediaType;

/**
 * 修改名称
 */
public class UpdateNameAModelImpl implements IUpdateNameAModel {
    @Override
    public <T> void setuser( String staffName,CallBack callBack) {
        HashMap<String, String> hashMap = new HashMap<String, String>();
        hashMap.put("staffName",staffName);

        OkHttpUtils.postString()
                .mediaType(MediaType.parse("application/json; charset=utf-8"))
                .addHeader("Content-Type", "application/json")
               .addHeader("Authorization", "Bearer " + SharedPreferenceUtil.getStringData("token"))
                .url(Urls.upstaffname)
                .content(new Gson().toJson(hashMap))
                .build().execute(new StringCallbacks() {
            @Override
            public void onError(Call call, Exception e, int id) {
            }
            @Override
            public void onResponse(String response, int id) {
                UpdateNameBean baseEntity= new Gson().fromJson(response, UpdateNameBean.class);
                callBack.onSuccess(baseEntity);
            }
        });
    }
}
